
public class Instruction {
	private String instruction;
	private Type type;
	private opCodeType opCode;
	public Instruction(){
		//Default Constructor 
	}
	
	
	
	public enum Type{
		ARITHMETIC,
		BRANCH,
		JUMP,
		IO;
	}
	
	public enum opCodeType{
		RD,
		WR,
		ST,
		LW,
		MOV,
		ADD,
		SUB,
		MUL,
		DIV,
		AND,
		OR,
		MOVI,
		ADDI,
		MULI,
		DIVI,
		LDI,
		SLT,
		SLTI,
		HLT,
		NOP,
		JMP,
		BEQ,
		BNE,
		BEZ,
		BNZ,
		BGZ,
		BLZ;		
	}
	
	public void setInstruction(String instruction){
		this.instruction = instruction;
		  
	}
	
	public String getInstruction(){
		return instruction;
	}
	
	public void setType(Type type){
		this.type = type;
	}
	
	public Type getType(){
		return type; 
	}
	
	public opCodeType getOpCode(){
		int number = Convert.binaryToInteger(instruction.substring(2,8));
		opCode = opCodeType.values()[number];
		return opCode;
	}
	
	public String getAddress(){
		switch(type){
		case ARITHMETIC:
			return instruction.substring(20);
		case BRANCH:
		case IO:			
			return instruction.substring(16);
		case JUMP:			
			return instruction.substring(8);
		}
		return null;
	}
	
	public String getRegister1(){
		return instruction.substring(8, 12);
	}
	
	public String getRegister2(){
		return instruction.substring(12, 16);
	}
	
	public String getRegister3(){
		return instruction.substring(16, 20);
	}
	
	
	
	
	

}
